<%--
	fileName      : menumgmt_main.jsp
	author        : kfzx-yuanjx1
	createDate    : 2010-6-24  上午10:40:28
	lastModifier  : kfzx-yuanjx1
	lastModifyDate: 2010-6-24  上午10:40:28
	description   : 请添加描述
--%>

<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8" %>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link type="text/css" rel="stylesheet" href="<ctp:out name='fullPath'/>css/ctpTree.css">
        <ctp:include items='checkboxgroup,radiogroup,textfield,gridlayout,combobox,form,textarea,label,groupbox,borderlayout,panel,toolbar,tabletree,button,multiselect,message_ex,validator'/>
    
		<script type='text/javascript' kind='variant'>		  
		     //================================UI变量定义片段============================================================
             var borderlayout;//页面框架布局器
             var menuToolBar;//工具栏
             var menuTabletree;//菜单表树
             var menuId_element; 
             var menuName_element;                                   
             var radio1_element;//菜单可使用级别                                     
             var radio2_element;//菜单使用机构             
             var menuBranchId_element;//机构编码             
             var menuLabel_element;
             var menuDesc_element;                          
             var checkboxgroup_element;//菜单可使用级别                                       
             var chooseButton_element;//选择按钮                          
             var combobox_element;//菜单状态			 			 
			 var multiselect_element;//功能结点列表				 			 		 
			 var menuRadioGroup;//菜单使用级别或机构选择
			 var menuNewPanel;//菜单管理详细信息panel
			 var menuDetailLayout;//菜单管理详细信息布局器
			 var menuDetailForm;//菜单管理详细信息form
			 var sublayout_branch;//菜单管理详细信息子布局器，菜单使用机构
			 //组件异步请求URL
			 var tableTreeUrl;      
			 var itemListUrl;
			 var itemListUrlDetail; 
			 var itemListJsonData;
			 //功能节点部分
			 var itemmgmtPanel;//功能节点详细信息panel
			 var itemDetailLayout1;//功能节点详细信息panel上半布局
			 var itemDetailLayout2;//功能节点详细信息panel下半布局
			 var itemIdShow;
			 var itemNameShow;
			 var itemStatusShow;//激活、冻结
			 var itemLabelShow;
			 var itemTypeShow;
			 var itemUrlShow;
			 var itemDescriptionShow;
			 var itemLvlRbox1Show;//功能可使用级别
			 var itemLvlRbox2Show;//仅本机构使用
			 var itemLevelShow;//顶级机构
			 var itemBranchIdShow;
			 
        </script>
       
        <script type='text/javascript' kind='event'>
            //================================函数定义片段============================================================
            var opFlag =''; 
            var selObj = new Object();
            var menuTreeOrderArray = new Array();
           /**********组件处理函数********/
            function dealAfterDomReady(){
                 var _mContext = "menumgmt.jsp -> dealAfterDomReady()";
                try {        
               //处理radioGroup
                menuRadioGroup = new ctp.ui.radiogroup({
                    id: 'branchRadioGroup'
                    //items: [menuDetailForm.getObj('radio1'), menuDetailForm.getObj('radio2')]
                });
                menuRadioGroup.addGroupItem([menuDetailForm.getObj('radio1'), menuDetailForm.getObj('radio2')]);
                
                menuRadioGroup.onChange(function(){
                    if (menuDetailForm.getObj('radio1').getValue() == '1') {
                        menuDetailForm.getObj('radio1').setValue('0');
                        menuDetailForm.getObj('radio2').setValue('1');
                        menuDetailForm.getObj('levelStr').setDisable(true);
                        menuDetailForm.getObj('chooseButton').setDisable(false);
                    }
                    else {
                        menuDetailForm.getObj('radio1').setValue('1');
                        menuDetailForm.getObj('radio2').setValue('0');
                        menuDetailForm.getObj('levelStr').setDisable(false);
                        menuDetailForm.getObj('chooseButton').setDisable(true);
                        menuDetailForm.getObj('menuBranchId').setValue('');
                    }
                });

            	 }
            	 catch (e) {
                     ctp.core.log.err(_mContext, e.message);
                 }                  
            }
            
        //tabletree操作
        function tabTrCallBack(){
            var _mContext = "menumgmt.jsp -> tabTrCallBack()";  
         try {                   
            menuTabletree.unDragByClass('noDrag');  
            menuTabletree.unInsertByClass('noDrag'); 
            //设置tabletree选中项                                         
            menuTabletree.selectRow(menuDetailForm.getHiddenInputValue('menuId'));  
            }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }                   
        } 
               
        function fun_select(e){
            var _mContext = "menumgmt.jsp -> fun_select()";  
         try {                                    
                    selObj = (menuTabletree.getSelectedObj())[0].ctp_ui_tableTree.data;                          
                if (selObj.menuId.charAt(0) != 'I') {//菜单结点
                    SelectMenu(selObj);
                }
                else {
                    SelectItem(selObj);
                }
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }                 
        }
 
        function afterDrag(param){        
            var tmpObj = new Object();        
            tmpObj.currentNodeId = param.find('.div4edit:eq('+1+')').html();//拖动节点
            tmpObj.parentNodeId = menuTabletree.getParent(param).find('.div4edit:eq('+1+')').html();//拖动后父节点
            tmpObj.prevNodeId = menuTabletree.getPrevSibling(param).find('.div4edit:eq('+1+')').html();//拖动后上一兄弟节点                                              
            menuTreeOrderArray.push(tmpObj);
            
   		 } 
 
               
        //机构选择
        function changeSelBranch(){
            var _mContext = "menumgmt.jsp -> changeSelBranch()";  
         try {                                
            var srcPath = '<ctp:url href="menumgmt.flowc" flowActionName="menumgmtBranchSelOp"/>&date=' + new Date();
            ctpMSB.win({
            message   :srcPath,
            width     :700,
            height    :400,
            title     :'<ctp:label key="query_result"/>',
            handler   :handler_branchSel,
            maxBtn    :true,
            minBtn    :true,
            iframe    :true
            }); 
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }                                          
         }
         
      /*********回调函数**********/           
      function handler_branchSel(retObj){
       var _mContext = "menumgmt.jsp -> handler_branchSel()";  
       try {                 
        if(retObj.flag == 'do') //弹出页面自定义
        {        
        menuDetailForm.getObj('menuBranchId').setValue(retObj.branchTree.id);
        }        
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }          
      }   


      //新增、修改、删除、排序后回调函数，删除后隐藏下部，刷新表树，将表树选择主键置空
       function handler_operation(){
       var _mContext = "menumgmt.jsp -> handler_operation()";  
       try {  
               if(opFlag == 'delete'){
               itemmgmtPanel.getJqDom().hide();//隐藏功能结点panel  
               menuNewPanel.getJqDom().hide();//隐藏菜单结点panel
               menuTabletree.reload(); 
               menuDetailForm.setHiddenValue('menuId','');    
               menuDetailForm.setHiddenValue('itemId','');          
               }
               else if(opFlag == 'order'){               
               menuTabletree.reload();
               //清空menuTreeOrderArray
               menuTreeOrderArray.length = 0;           
               }
               else{               
               setReadOnly();//设置只读                        	
               menuTabletree.reload();                                                   
               }

             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }             
          }
            
       function menuFormSucc(data){                        
                            if (data[0].out_flag == '0') //成功
                            {                                
                             if(opFlag == 'add'){   
                                ctpMSB.succeed({
                                    message: '<ctp:label key="add_success"/>',
                                    handler: handler_operation
                                });
                             }else if(opFlag == 'modify'){
                                ctpMSB.succeed({
                                    message: '<ctp:label key="modify_success"/>',
                                    handler: handler_operation
                                });                             
                             
                             } 
                               
                            }
                            else {
                                ctpMSB.error({
                                //错误码对应错误信息
                                    message: data[0].errorMsg
                                });
                                return;
                            }
                            
                        }            



      /*******菜单详细页面组件操作函数**********/       
       function prepareForDetail(tmpObj){
       var _mContext = "menumgmt.jsp -> prepareForDetail()";  
       try {            
        ctp.util.closeAllPrompt();//关掉页面上所有验证框架产生的提示框            
        //新增，父节点
        menuDetailForm.setHiddenValue('menuParentId',tmpObj.menuId);              
        //详细页面，设置属性
        menuDetailForm.getObj('menuId1').setValue(tmpObj.menuId);//菜单编号
        menuDetailForm.getObj('menuName').setValue(tmpObj.menuName);//菜单名称
        menuDetailForm.getObj('menuLabel').setValue(tmpObj.menuLabel);//显示文字
        menuDetailForm.getObj('menuBranchId').setValue(tmpObj.menuBranchId);//机构编码
        menuDetailForm.getObj('menuDesc').setValue(tmpObj.menuDesc);//菜单描述        
        menuDetailForm.getObj('menuStatus').setSelectedByIndex(tmpObj.menuStatus*1);//菜单状态
        //处理radiogroup   			     	
        if(tmpObj.menuBranchId!=""){	
        menuDetailForm.getObj('radio2').setChecked(true);//选中仅被本机构维护的单选按钮	
        menuDetailForm.getObj('radio2').setValue('1');
        menuDetailForm.getObj('radio1').setValue('0');}        
        else{
        menuDetailForm.getObj('radio1').setChecked(true);//选中可维护本角色的级别的单选按钮
        menuDetailForm.getObj('radio1').setValue('1'); 
        menuDetailForm.getObj('radio2').setValue('0');}      
        //处理checkboxgroup
        menuDetailForm.getObj('levelStr').delAllItems();        
        var level=tmpObj.menuLevel;
        var flag = false;
        if(level.charAt(0) == '1') flag = true;
        menuDetailForm.getObj('levelStr').addGroupItem([{id:'levelStr0',label: '<ctp:label key="top_org"/>',value: '0',checked:flag}]);
        
        var maxLevel = "<ctp:out name='flowCtx.maxBranchLevel'/>"; 
        for(var i=1;i<maxLevel;i++)
            {   if(level.charAt(i) == '1') {flag = true} else {flag = false};
            	menuDetailForm.getObj('levelStr').addGroupItem([{id:'levelStr'+i,label: '<ctp:label key="underling_level"/>'+i,value: i,checked:flag}]);         
            	}               
       //处理multiselect， 功能结点 
       itemListUrlDetail='<ctp:url href="menumgmt.flowc" flowActionName="itemListUnderMenuOp" />&menuId='+tmpObj.menuId+'&date='+new Date(); 
       menuDetailForm.getObj('funcNodeList').reloadData({url:itemListUrlDetail});
       //设置只读                 
       setReadOnly();	                                                                                                                         
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }         
        }

       
    function prepareForNew(){ 
       var _mContext = "menumgmt.jsp -> prepareForNew()";  
       try {                
        ctp.util.closeAllPrompt();//关掉页面上所有验证框架产生的提示框  
        //新增页面，设置属性
        menuDetailForm.getObj('menuId1').setValue('');//菜单编号
        menuDetailForm.getObj('menuName').setValue('');//菜单名称
        menuDetailForm.getObj('menuLabel').setValue('');//显示文字
        menuDetailForm.getObj('menuBranchId').setValue('');//机构编码
        menuDetailForm.getObj('menuDesc').setValue('');//菜单描述                
        menuDetailForm.getObj('menuStatus').setValue('');//菜单状态        
        //处理radiogroup   			     		
        menuDetailForm.getObj('radio1').setChecked(true);//选中可维护本角色的级别的单选按钮
        menuDetailForm.getObj('radio1').setValue('1');            
        menuDetailForm.getObj('radio2').setChecked(false);//选中仅被本机构维护的单选按钮	
        menuDetailForm.getObj('radio2').setValue('0');   
        //处理checkboxgroup
        menuDetailForm.getObj('levelStr').delAllItems();   
        menuDetailForm.getObj('levelStr').addGroupItem([{id:'levelStr0',label: '<ctp:label key="top_org"/>',value: '0'}]);     
        var level = "<ctp:out name='flowCtx.maxBranchLevel'/>";  
          for (var i = 1; i < level; i++) {
                    menuDetailForm.getObj('levelStr').addGroupItem([{
                        id: 'levelStr' + i,
                        label: '<ctp:label key="underling_level"/>' + i,
                        value: i
                    }]);                    
                }                       
                
       //处理multiselect， 功能结点 
       menuDetailForm.getObj('funcNodeList').reloadItems(itemListJsonData); 
       //设置可编辑 
       menuDetailForm.setDisableType(["textfield","textarea","checkboxgroup","radio","combobox","button","multiselect"],false);                                         
       menuDetailForm.getObj('chooseButton').setDisable(true);         
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }                
        }
        
     function prepareForModify(){  
       var _mContext = "menumgmt.jsp -> prepareForModify()";  
       try {        
       SelectMenu(selObj);//重新触发选择操作， selObj为全局变量，保存但前结点信息         
       //设置可编辑 
       menuDetailForm.setDisableType(["textfield","textarea","checkboxgroup","radio","combobox","button","multiselect"],false);                                             
       menuDetailForm.getObj('menuId1').setDisable(true);       
       if(menuDetailForm.getObj('radio1').getValue() == '1'){                                             
                                                         menuDetailForm.getObj('chooseButton').setDisable(true);          
                                                   }else{
                                                         menuDetailForm.getObj('levelStr').setDisable(true);
                                                   }                 
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }        
       }  
      
        //选择功能结点
      function SelectItem(tmpObj){
       var _mContext = "menumgmt.jsp -> SelectItem()";  
       try {          
            menuDetailForm.setHiddenValue('itemId',tmpObj.menuId);
            menuDetailForm.setHiddenValue('menuId',tmpObj.menuParentId);
            menuToolBar.setDisable("funcAdd",true);
            menuToolBar.setDisable("funcModify",true);  
            menuNewPanel.getJqDom().hide(); //隐藏菜单节点panel
                        
            itemIdShow.setValue(tmpObj.menuId);
            itemNameShow.setValue(tmpObj.itemName);
            itemLabelShow.setValue(tmpObj.menuLabel);
            itemDescriptionShow.setValue(tmpObj.itemDescription);
            itemUrlShow.setValue(tmpObj.itemUrl);
            itemBranchIdShow.setValue(tmpObj.itemBranchid);
            itemStatusShow.setValue(tmpObj.itemStatus);
            itemTypeShow.setValue(tmpObj.itemType);
            
            itemLevelShow.delAllItems();
            
            
            var level = "<ctp:out name='flowCtx.maxBranchLevel'/>";             
            var lvlItems=[];
            lvlItems.push({id:'lvl0',label:'<ctp:label key="itemmgmt.rootbranch.label"/>',value:'0'});//下属级别
            for (var i=1;i<level;i++){
                  lvlItems.push({id:'lvl'+i,label:'<ctp:label key="itemmgmt.subbranch.label"/>:'+i,value:i});//下属级别
                  }
            itemLevelShow.addGroupItem(lvlItems);              
            
            if(tmpObj.itemLevel.length>0){
               itemLvlRbox1Show.setChecked(true);
               itemLvlRbox2Show.setChecked(false);
               itemBranchIdShow.setValue('');
           
               var val=[];                          	
                	for(var j = 0;j<tmpObj.itemLevel.length;j++){
                    	var _tmp = tmpObj.itemLevel.substr(j,1);
                    	if(_tmp=="1"){
                    		val.push(j);
                    	}
                	}
                	if(val.length>0){
                		val=val.join(",");
                		itemLevelShow.setValue(val);
                	}    
                              
            }else{//仅本机构使用
               itemLvlRbox1Show.setChecked(false);
               itemLvlRbox2Show.setChecked(true);
               itemBranchIdShow.setValue(tmpObj.itemBranchid);                	                 
                }            
            itemmgmtPanel.getJqDom().show();//显示功能结点panel   
            //itemmgmtPanel.render(); 
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }           
        }
        
        //选择菜单结点
       function SelectMenu(tmpObj){
       var _mContext = "menumgmt.jsp -> SelectItem()";  
       try {    
            opFlag = 'modify';
            menuDetailForm.setHiddenValue('menuId',tmpObj.menuId);
            menuDetailForm.setHiddenValue('itemId','');            
            menuToolBar.setDisable("funcAdd",false);
            menuToolBar.setDisable("funcModify",false); 
            itemmgmtPanel.getJqDom().hide();//隐藏功能结点panel 
            menuNewPanel.getJqDom().show();//显示菜单结点panel 
            //menuNewPanel.render();             
            //准备详细页面信息
            prepareForDetail(tmpObj);
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }                                
        }
         
      
      function funcAdd(){     
       var _mContext = "menumgmt.jsp -> funcAdd()";  
       try {  
            opFlag = 'add';
            if (menuDetailForm.getHiddenInputValue('menuId') == "") {
                ctpMSB.alert({message:"<ctp:label key='select_menu_before_press_insertbutton'/>"});
                return;
            }            
            prepareForNew();            
            return;
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }              
        }
        
      function funcModify(){
       var _mContext = "menumgmt.jsp -> funcModify()";  
       try {      
            opFlag = 'modify';   
            if (menuDetailForm.getHiddenInputValue('menuId') == "") {
                ctpMSB.alert({message:"<ctp:label key='select_menu_before_press_modifybutton'/>"});
                return;
            }
            prepareForModify();
            return;
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }              
        }
                        
       function confirmDelete(){ 
       var _mContext = "menumgmt.jsp -> confirmDelete()";  
       try {          
           if(selObj.menuParentId == ''){//根节点不允许删除
                ctpMSB.alert({message:"<ctp:label key='root_menunode_before_cannot_bedeleted'/>"});
                return;
           }
           if (menuDetailForm.getHiddenInputValue('menuId') == "" && menuDetailForm.getHiddenInputValue('itemId') == "") {
                ctpMSB.alert({message:"<ctp:label key='select_menu_before_press_delbutton'/>"});
                return;
            }            
            ctpMSB.confirm({message:'<ctp:label key="menumgmt_confirm_delete"/>',handler:funcDelete});                      
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }          
        }
        
       function funcDelete(tp){
       var _mContext = "menumgmt.jsp -> funcDelete()";  
       try {         
       opFlag = 'delete';
        if(tp == 'ok'){            
            //删除菜单结点
            if (menuDetailForm.getHiddenInputValue('itemId') == "" && menuDetailForm.getHiddenInputValue('menuId') != "") {			                	
                ctp.data.getJSONA({
                			        url:'<ctp:url href="menumgmt.flowc" flowActionName="deleteMenuNodeOp"/>&menuId='+menuDetailForm.getHiddenInputValue('menuId'),
                			    success:function(data){
                			        		if(data[0].out_flag && data[0].out_flag=='0'){
                                              ctpMSB.succeed({
                                                    message: '<ctp:label key="delete_success"/>',
                                                    handler: handler_operation
                                                            }); 
                			        					 }else {
                                                              ctpMSB.error({//错误码对应错误信息
                                                                        message: data[0].errorMsg
                                                                             });
                                                                return;
                                                                }
                			        		 		  },
                			     error:function(XMLHttpRequest, textStatus, errorThrown){
                			                  ctpMSB.error({message:textStatus});//提示删除异常，并告之错误原因
                			        		 		 }            			        		 		 
                			                     });         
              return;       			                            
            }            
            //删除功能结点   
            if (menuDetailForm.getHiddenInputValue('menuId') != "" && menuDetailForm.getHiddenInputValue('itemId') != "") {
                ctp.data.getJSONA({
                			        url:'<ctp:url href="menumgmt.flowc" flowActionName="deleteItemNodeOp"/>&menuId='+menuDetailForm.getHiddenInputValue('menuId')+'&itemId='+menuDetailForm.getHiddenInputValue('itemId'),
                			    success:function(data){
                			        		if(data[0].out_flag && data[0].out_flag=='0'){
                                              ctpMSB.succeed({
                                                    message: '<ctp:label key="delete_success"/>',
                                                    handler: handler_operation
                                                            }); 
                			        					 }else {
                                                              ctpMSB.error({//错误码对应错误信息
                                                                        message: data[0].errorMsg
                                                                             });
                                                                return;
                                                                }
                			        		 		  },
                			     error:function(XMLHttpRequest, textStatus, errorThrown){
                			                  ctpMSB.error({message:textStatus});//提示删除异常，并告之错误原因
                			        		 		 }            			        		 		 
                			                     });                  
                return;
            }
          }
        else return;  
             }
            catch (e) {
                     ctp.core.log.err(_mContext, e.message);
            }               
        }
        
        
        function modifyOrder(){//修改显示顺序              
                    
          if(menuTreeOrderArray.length == 0) {
                 ctpMSB.alert({message: '<ctp:label key="modify_order_first"/>'});                     
          return;
          }
          opFlag = 'order';
          var tempArr = new Array();         
          tempArr.push('[');
        //创建json.Map
         for(var i=0;i<menuTreeOrderArray.length;i++){         
            tempArr.push('{');
            tempArr.push('"currentNodeId":"'+menuTreeOrderArray[i].currentNodeId+'",');
            tempArr.push('"parentNodeId":"'+menuTreeOrderArray[i].parentNodeId+'",');
            tempArr.push('"prevNodeId":"'+(menuTreeOrderArray[i].prevNodeId == null?'':menuTreeOrderArray[i].prevNodeId));
            tempArr.push('"}');
            if(i < menuTreeOrderArray.length-1) tempArr.push(',');
              }    
            tempArr.push(']');    
       
            ctp.data.getJSONA({
                			        url:'<ctp:url href="menumgmt.flowc" flowActionName="updateorder"/>&json.menuOrderList='+tempArr.join(''),
                			    success:function(data){
                			        		if(data[0].out_flag && data[0].out_flag=='0'){
                                             ctpMSB.succeed({
                                                   message: '<ctp:label key="order_success"/>',
                                                   handler: handler_operation
                                                            });     
                			        					 }else {
                                                              ctpMSB.error({//错误码对应错误信息
                                                                        message: data[0].errorMsg
                                                                             });
                                                                return;
                                                                }
                			        		 		  },
                			     error:function(XMLHttpRequest, textStatus, errorThrown){ 
                			                  ctpMSB.error({message:textStatus});//提示删除异常，并告之错误原因
                			        		 		 }            			        		 		 
                			                     });                   

        }        
        
        
        function menuFormAdd(){
                                beforeSubmit();                                                               
                                //区分新增和修改
                                if(opFlag == 'modify'){ menuDetailForm.setHiddenValue('flowActionName','updateMenuNodeOp');}  
                                else if(opFlag == 'add'){menuDetailForm.setHiddenValue('flowActionName','addMenuNodeOp');} 
                                else return;                                                  
                                menuDetailForm.submit();                                
                            }                                                         
                                                
       function menuFormCancel(){
                               if(opFlag == 'add'){
                               prepareForNew();
                               }else if(opFlag == 'modify'){                             
                               SelectMenu(selObj);//重新触发选择操作， selObj为全局变量，保存但前结点信息       
                               prepareForModify();//置为修改状态
                               }      
       }                                         
       
       function setReadOnly(){
                     //设置只读                 
                    menuDetailForm.setDisableType(["textfield","textarea","checkboxgroup","radio","combobox","button","multiselect"],true);
       }                                                
       </script>
        
	<script type='text/javascript' kind='ui'>
	//================================UI组件定义片段============================================================		
       function initUI(){
          var _mContext = "menumgmt_main.jsp -> window.load";              
          try{ 
			  tableTreeUrl = '<ctp:url href="menumgmt.flowc" flowActionName="queryMenuListOp" />&date=' + new Date();      
			  itemListUrl = '<ctp:url href="menumgmt.flowc" flowActionName="itemListOp" />&data=' + new Date();
			  itemListJsonData = ctp.data.getJSON(itemListUrl);                                          
              //菜单
              menuId_element = new ctp.ui.textfield({id: 'menuId1',validate: 'rules[required,letterOrNumber,length[0,7]]',width: '100%'});  
              menuName_element = new ctp.ui.textfield({id: 'menuName',validate: 'rules[required,length[0,50],custom[menuNameValidFunc]]',width: '100%'});                                   
              radio1_element = new ctp.ui.radio({id: 'radio1',label: '<ctp:label key="createment_canuse_grade"/>:',checked: true,value: '1'});//菜单可使用级别                                     
              radio2_element =new ctp.ui.radio({id: 'radio2',label: '<ctp:label key="createment_only_use_by_this_org"/>:',value: '0' });//菜单使用机构             
              menuBranchId_element = new ctp.ui.textfield({id: 'menuBranchId',readOnly: true ,validate:'rules[custom[menuUseBranchValidFunc]]',width: '100%'});//机构编码             
              menuLabel_element = new ctp.ui.textarea({id: 'menuLabel',validate: 'rules[required,length[0,40],custom[menuLabelValidFunc]]',width: '100%',rows:"4"});
              menuDesc_element = new ctp.ui.textarea({id: 'menuDesc',validate: 'rules[length[0,500]]',width: '100%',rows:"4"});                          
              checkboxgroup_element = new ctp.ui.checkboxgroup({id: 'levelStr',display: 'cols',itemWidth: 'auto',validate:'rules[custom[menuUseLevelValidFunc]]'});//菜单可使用级别                                       
              chooseButton_element = new ctp.ui.button({id: 'chooseButton',text: '<ctp:label key="select_btn"/>',disabled: true,onClick:function(){changeSelBranch();},width: '100%'});//选择按钮                          
              combobox_element = new ctp.ui.combobox({id: 'menuStatus',items: [{text: '<ctp:label key="freeze"/>',value: '0'}, {text: '<ctp:label key="activation"/>',value: '1' }],validate: 'rules[required]',width: '100%'});//菜单状态			 			 
			  multiselect_element = new ctp.ui.multiselect({id: 'funcNodeList',items:itemListJsonData,width: '95%'});//功能结点列表	          
              //功能
			  itemIdShow=new ctp.ui.textfield({id: 'itemIdShow',width:'100%',disabled:true});
			  itemNameShow=new ctp.ui.textfield({id: 'itemNameShow',width:'100%',disabled:true});
			  itemStatusShow=new ctp.ui.radiogroup({id:'itemStatusShow',items:[{id:'stat1',label:'<ctp:label key="itemmgmt.active.label"/>',value:"1"},{id:'stat2',label:'<ctp:label key="itemmgmt.freeze.label"/>',value:"0"}],display:"cols",width:"100%",disabled:true});//激活、冻结
			  itemLabelShow=new ctp.ui.textfield({id: 'itemLabelShow',width:'100%',disabled:true});
			  itemTypeShow=new ctp.ui.radiogroup({id:'itemTypeShow',items:[{id:'type1',label:'opg',value:"2"},{id:'type2',label:'jsp',value:"1"}],display:"cols",width:"100%",disabled:true});
			  itemUrlShow=new ctp.ui.textarea({id:'itemUrlShow',width:'100%',rows:"2",disabled:true});
			  itemDescriptionShow=new ctp.ui.textarea({id:'itemDescriptionShow',width:'100%',rows:"2",disabled:true});
			  itemLvlRbox1Show=new ctp.ui.radio({id:'itemLvlRbox1Show',label:'<ctp:label key="itemmgmt.uselvl.label"/>',value:"0",width:"100%",disabled:true});//功能可使用级别
			  itemLvlRbox2Show=new ctp.ui.radio({id:'itemLvlRbox2Show',label:'<ctp:label key="itemmgmt.usebranch.label"/>',value:"1",width:"100%",disabled:true});//仅本机构使用
			  itemLevelShow=new ctp.ui.checkboxgroup({id:'itemLevelShow',display:"cols",width:"100%",disabled:true});//顶级机构
			  itemBranchIdShow=new ctp.ui.textfield({id: 'itemBranchIdShow',disabled:true});          
                     
            /************菜单列表布局************/
		               
            //工具栏
            menuToolBar = new ctp.ui.toolbar({
                id: 'toolBar',
                border: 'bottom',
                leftItems: [{
                    id: 'funcAdd',
                    type: 'button',
                    text: '<ctp:label key="newinbutton"/>',
                    icon: 'add',
                    disabled: false,
                    onClick: funcAdd
                }, '-', {
                    id: 'funcModify',
                    type: 'button',
                    text: '<ctp:label key="modify_btn"/>',
                    icon: 'edit',
                    disable: false,
                    onClick: funcModify
                }, '-', {
                    id: 'delete',
                    type: 'button',
                    text: '<ctp:label key="delbutton"/>',
                    icon: 'delete',
                    disable: false,
                    onClick: confirmDelete
                }, '-', {
                    id: 'order',
                    type: 'button',
                    text: '<ctp:label key="update_menu_list_code"/>',
                    icon: 'reload',
                    disable: false,
                    onClick: modifyOrder
                }]
            });

            //表树
            menuTabletree = new ctp.ui.tabletree({
                actionPos: 2,                
                check: true,
                height:'100%',
                width:'auto',
                dragNode:true,
                blockKeyColEvent:false,
                nodeImgUrlPrefix:CTP_WEB_FULLPATH,
                tableHead: [[{
                    text: '<ctp:label key="select"/>',
                    width: '50px'
                }, {
                    text: '<ctp:label key="menu_module_name"/>',
                    width: '500px'
                }, {
                    text: '<ctp:label key="menu_module_code"/>'
                }, {
                    text: '<ctp:label key="menu_display_num"/>'
                }]],
                url: tableTreeUrl,
                id: 'menuTabletree',
                onSelect:fun_select,
                onInit:tabTrCallBack,
                onDragEnd:afterDrag
            });
    
           /**********菜单详细页面布局****************/
                //子布局，菜单使用行级别
                sublayout_grade = new ctp.ui.gridlayout({
                    cols: 9,
                    defaults: {display: 'h',align: 'center',label: {width: '100px'},element: {type: 'textfield'}},
                    items: [[
                            {colspan: 2,element: radio1_element}, 
                            {colspan: 7,element: checkboxgroup_element}
                           ]]
                
                });
                //子布局，菜单使用机构
                sublayout_branch = new ctp.ui.gridlayout({
                    cols: 9,
                    defaults: {display: 'h',align: 'center',label: {width: '100px'},element:{type: 'textfield'}},
                    items: [[
                             {colspan: 2,element: radio2_element}, 
                             {colspan: 3,element: menuBranchId_element}, 
                             {element: chooseButton_element}, 
                             {colspan: 3,label: {text: '<ctp:label key="createment_press_button_to_select"/>',width: '300px'}}
                           ]]                
                });
       
                //菜单详细页面布局
                menuDetailLayout = new ctp.ui.gridlayout({
                    width: '95%',
                    align: 'center',
                    colSpace: 30,
                    defaults: {display: 'h',align: 'center',label: {width: '100px'},element: {type: 'textfield'}},
                    items: [[
                             {label:{text: '<ctp:label key="createment_menu_code"/><font color="#FF0000">*</font>:'},element:menuId_element},                              
                             {label: {text: '<ctp:label key="createment_menu_name"/><font color="#FF0000">*</font>:'},element:menuName_element}
                            ],                      
                            [
                             {label: {text: '<ctp:label key="createment_menu_display_character"/><font color="#FF0000">*</font>:'},element:menuLabel_element },                                                         
                             {label: {text: '<ctp:label key="createment_menu_description"/>:'},element: menuDesc_element}
                            ], 
                            [
                             {label: {text: '<ctp:label key="createment_menu_state"/><font color="#FF0000">*</font>:'},element: combobox_element}
                            ],                            
                            [
                             {colspan: 2,element: sublayout_grade}
                            ], 
                            [
                            {colspan: 2, element: sublayout_branch}
                            ], 
                            [
                            {colspan: 2,label: {text: '<ctp:label key="func_node"/>:'},element: multiselect_element}
                            ]]
                   });
				
				
				//功能结点栅格布局（上部）
                itemDetailLayout1=new ctp.ui.gridlayout({                    
					cols: 2,
					align: 'center',
					colSpace: 30,
					defaults: {display: 'h',align: 'center',label:{width:'100px'},element:{type:'textfield',options:{disabled:true}}},					
					items: [
					   [{label: {text: '<ctp:label key="itemmgmt.id.label"/><font color="#FF0000">*</font>:'},element: itemIdShow},
					    {label: {text: '<ctp:label key="itemmgmt.name.label"/><font color="#FF0000">*</font>:'},element: itemNameShow}
					   ],
					   [{label: {text: '<ctp:label key="itemmgmt.status.label"/><font color="#FF0000">*</font>:'},element: itemStatusShow},
					    {label: {text: '<ctp:label key="itemmgmt.text.label"/><font color="#FF0000">*</font>:'},element: itemLabelShow}
					   ],
					   [{colspan: 2,label: {text: '<ctp:label key="itemmgmt.type.label"/><font color="#FF0000">*</font>:'},element: itemTypeShow}]
					]                          
                        
                });
			    //功能结点栅格布局（下部）   
                itemDetailLayout2=new ctp.ui.gridlayout({
					cols: 6,
					align: 'center',
					colSpace: 20,
					defaults: {display: 'h',align: 'center',label:{width:'100px'},element:{type:'textfield'}},					
					items: [
					   [{colspan: 5,label: {text: '<ctp:label key="itemmgmt.url.label"/><font color="#FF0000">*</font>:'},element: itemUrlShow }],//指向地址
					   [{colspan: 6,label: {text: '<ctp:label key="itemmgmt.description.label"/>:'},element: itemDescriptionShow}],//功能描述
					   [{element: itemLvlRbox1Show,align:"left"},//可使用级别
						{colspan: 5,element: itemLevelShow,align:"left"}//顶级机构...
					   ],
					   [
						{element: itemLvlRbox2Show,align:"left"},//仅本机构使用
						{colspan: 2,element: itemBranchIdShow,align:"left"}//机构代码文本框
					   ]
					]
                });	                   

            /*************创建form*************/ 
                menuDetailForm = new ctp.form({
                    id: 'menuDetailForm',
                    width: '96%', //宽度
                    height: 'auto', //高度
                    validator:menuValidator,
                    items: menuDetailLayout,
                    postType: 'ajax',
                    ajaxPostParam: {success: menuFormSucc},
                    buttons: [{
                        id: 'addButton',
                        text: '<ctp:label key="apply_btn"/>',
                        icon: 'apply',
                        onClick: menuFormAdd
                       
                    },{
                        id: 'resetButton',
                        text: '<ctp:label key="reload_btn"/>',
                        icon:'reload',
                        onClick:menuFormCancel
                             }]
                });
                
           /*************创建panel*****************/      
              //菜单节点部分    
              menuNewPanel = new ctp.ui.panel({
                    id: 'menuNewPanelId',
                    title: '<ctp:label key="menu_node_detail"/>',
                    width: 'auto',
                    height: '100%',
                    items: [menuDetailForm]
                });              
                  
			 //功能节点部分
			  itemmgmtPanel=new ctp.ui.panel({
					id: 'itemPanelId',
					width:"auto",
					height:"100%",
					title:'<ctp:label key="itemmgmt.detail.title.label"/>',//功能详情
					items:[itemDetailLayout1,itemDetailLayout2]
				});

				//整体布局器
			    borderlayout=new ctp.ui.borderlayout({
	                    type: "2E",
	                    north__resizable: true,
	                    north__size: 0.455,
	                    north__items:[menuToolBar,menuTabletree],
	                    center__items:[menuNewPanel,itemmgmtPanel],
	                    renderTo:"body"
	            });

				
			  	itemmgmtPanel.getJqDom().hide();//隐藏
			 			                                       	
               /*****详细信息组件加载完成后处理函数 *****/            
                setReadOnly();//设置只读  
                dealAfterDomReady(); 			 
           }	
           catch (e) {
                 ctp.core.log.err(_mContext, e.message);
            }                                
       };       
        
        </script>
        
    <script type='text/javascript' kind='notUi'>    
    //================================非UI组件定义片段==========================================================        
      var menuValidator = new ctp.validator({
                                      id:"menuFormValidator",
                                      customRex: {
                                                 "menuNameValidFunc": {
                                                 "isValidateEmpty":true,
                                                 "regex": menuNameValidFunc,
                                                 "alertText": "<ctp:label key='createment_menu_menuname_validator'/>"
                                                                     },
                                                 "menuLabelValidFunc": {
                                                 "isValidateEmpty":true,
                                                 "regex": menuLabelValidFunc,
                                                 "alertText": "<ctp:label key='createment_menu_menuname_validator'/>"
                                                                     },                                                                     
                                                 "menuUseLevelValidFunc": {
                                                 "isValidateEmpty":true,
                                                 "regex": menuUseLevelValidFunc,
                                                 "alertText": "<ctp:label key='menu_select_level'/>"
                                                                           },
                                                 "menuUseBranchValidFunc": {
                                                 "isValidateEmpty":true,
                                                 "regex": menuUseBranchValidFunc,
                                                 "alertText": "<ctp:label key='menu_select_organization'/>"
                                                                           }
                                                 }                                                 
                                           });//验证框架    
                 
            
            /*****自定义验证函数***/
            function menuNameValidFunc(){
             var _mContext = "menumgmt.jsp -> menuNameValidFunc()";  
             try {
                 // 创建正则表达式模式。     
                 var reg = /^[^'"\\()@$%^*<>&?]*$/;    
	             if (reg.exec(menuDetailForm.getObj('menuName').getValue()) == null) {
		             return false;
	              } else {
		             return true;
	              }
             }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }                  
         }
         
            function menuLabelValidFunc(){
             var _mContext = "menumgmt.jsp -> menuLabelValidFunc()";  
             try {
                 // 创建正则表达式模式。     
                 var reg = /^[^'"\\@$%^*<>&?]*$/;    
	             if (reg.exec(menuDetailForm.getObj('menuLabel').getValue()) == null) {
		             return false;
	              } else {
		             return true;
	              }
             }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }                  
         }         
         
         
         
         
            function menuUseLevelValidFunc(){
               var _mContext = "menumgmt.jsp -> menuUseLevelValidFunc()"; 
                 try {
                if (menuDetailForm.getObj('radio1').getValue() == '1') {
                        return levelSetCheck();
                }
                return true;              
              }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }            
            }            
           
          
            function menuUseBranchValidFunc(){
               var _mContext = "menumgmt.jsp -> menuUseBranchValidFunc()"; 
                 try {
                      if(menuDetailForm.getObj('radio2').getValue() == '1'){
                       if (menuDetailForm.getObj('menuBranchId').getValue() == '') return false;                                      
                         } 
                      return true;
              }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }              
            }

          
            function levelSetCheck(){                                    
             var _mContext = "menumgmt.jsp -> levelSetCheck()";  
             try {                              
               var tmpStr = "";              
                if (menuDetailForm.getObj('levelStr').isGroupUnchecked()) {
                    return false;
                }                              
               for (var i = 0; i < menuDetailForm.getObj('levelStr').getItemCount(); i++) {
                    if ( menuDetailForm.getObj('levelStr').isItemChecked("levelStr"+i) == true) {
                        tmpStr = tmpStr + '1';
                    }
                    else {
                        tmpStr = tmpStr + '0';
                    }
                }                                                            
                menuDetailForm.setHiddenValue('menuLevel',tmpStr);
                return true;
             }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }              
            }
            
           
           /************提交前处理函数************/
           function beforeSubmit(){
             var _mContext = "menumgmt.jsp -> beforeSubmit()";  
             try {                                    
                //菜单编号
                if(opFlag == 'add'){
                 menuDetailForm.setHiddenValue('menuId','M' + menuDetailForm.getObj('menuId1').getValue());
                }
                else{
                menuDetailForm.setHiddenValue('menuId',menuDetailForm.getObj('menuId1').getValue());
                }              
                //功能结点
                menuDetailForm.setHiddenValue('itemId',menuDetailForm.getObj('funcNodeList').getValue());
             }	
             catch (e) {
                 ctp.core.log.err(_mContext, e.message);
             }            
            }               
                    
    </script>       
    </head>
    <body onload='initUI();'>
    <ctp:form name="menuDetailForm" method="post" action="menumgmt.flowc" flowActionName="">
            <input type="hidden"  name="menuId">
            <input type="hidden"  name="itemId">
            <input type="hidden"  name="menuParentId">            
            <input type="hidden"  name="menuLevel">
            <input type="hidden"  name="menuType"/>
            <input type="hidden"  name="menuOrder"/>
            <input type="hidden"  name="menuSerialNo"/>
   </ctp:form>            
    </body>
</html>